package com.cskaoyan.config2;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author stone
 * @date 2022/06/02 14:35
 */
// @Configuration
public class DruidConfiguration2 {

    @Value("${cskaoyan.datasource.driverClassName}")
    String driverClass;  // "com.mysql.jdbc.Driver";
    @Value("${cskaoyan.datasource.url}")
    String jdbcUrl;  // "jdbc:mysql://localhost:3306/cskaoyan_db?useUnicode=true&characterEncoding=utf-8";

    @Value("${cskaoyan.datasource.username}")
    String root;  // "root";
    @Value("${cskaoyan.datasource.password}")
    String password;  // "123456";
    @Bean
    public DruidDataSource dataSource2() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(jdbcUrl);
        dataSource.setUsername(root);
        dataSource.setPassword(password);
        return dataSource;
    }
}
